home *** CD-ROM | disk | FTP | other *** search
/ CD Exchange / CD Exchange - Volume 1.iso / d.t.p / utils / propage / donsgenies / donsgenies.lha / Don'sGenies / BoxesNameAll.pprx < prev    next >
Text File  |  1993-05-25  |  3KB  |  106 lines

  1. /* Boxes Name All
  2. This genie gives a name to all the boxes in the document. The box number is added to the end of the name. Existing names are not altered, except for having the number added.
  3. Written by Don Cox    July 92  Not Public Domain. All rights reserved.*/
  4.  
  5. trace n
  6.  
  7. signal on error
  8. signal on syntax
  9. call ppm_AutoUpdate(0)
  10. cr = "0a"x
  11.  
  12. address command
  13. call SafeEndEdit.rexx()
  14.  
  15. call ppm_ShowStatus("   Naming Boxes ...")
  16. thispage = ppm_CurrentPage()
  17. pages = ppm_NumPages()
  18. do p = 1 to pages
  19.     newpage = ppm_GoToPage(p)
  20.  
  21.     totalboxes = ppm_NumBoxes(newpage)
  22.     box = ppm_PageFirstBox()
  23.     do i = 1 to totalboxes
  24.         number = right(ppm_BoxNum(box),3,"0") 
  25.         info = ppm_GetBoxInfo(box)
  26.         boxtype = word(info,1)
  27.         boxname = createboxname(box)
  28.         call ppm_SetBoxName(box, boxname)
  29.         box = ppm_PageNextBox(box)
  30.         end
  31. end
  32. call ppm_GoToPage(thispage)
  33. exit_msg("Boxes now all named.")
  34.  
  35. error:
  36. syntax:
  37.     do
  38.     exit_msg("Genie failed due to error: "errortext(rc))
  39.     end
  40.  
  41. exit_msg:
  42.     do
  43.     parse arg message
  44.     if message ~= "" then
  45.     call ppm_Inform(1,message)
  46.     call ppm_ClearStatus()
  47.     call ppm_AutoUpdate(1)
  48.     exit
  49.     end
  50.  
  51.  
  52. createboxname: procedure
  53. parse arg box
  54. number = right(ppm_BoxNum(box),3,"0") 
  55. info = ppm_GetBoxInfo(box)
  56. boxtype = word(info,1)
  57. boxname = ppm_GetBoxName(box)
  58.  
  59. if upper(left(boxname,5))="EMPTY" then boxname = ""
  60. numbered = 0
  61. if boxname ~="" then do
  62.     endbit = right(boxname,5)
  63.     if verify(endbit,"()0123456789")=0 then numbered = 1
  64.     end
  65.  
  66. select
  67.     when upper(boxtype) = "TEXT" then do
  68.         boxtext = ppm_GetBoxText(box,0)
  69.         shorttext = substr(boxtext,1,16)
  70.         shorttext = '"'||shorttext||'"'
  71.         if boxname = "" then boxname = shorttext
  72.         end
  73.     when upper(boxtype) = "BITMAP" then do
  74.         filename = word(info,5)
  75.         endofpath = lastpos("/",filename)
  76.         if endofpath = 0 then endofpath = pos(":",filename)
  77.         filename = substr(filename, endofpath+1)
  78.         if boxname = "" then boxname = filename
  79.         end
  80.     when upper(boxtype) = "EPSF" then do
  81.         filename = word(info,3)
  82.         endofpath = lastpos("/",filename)
  83.         if endofpath = 0 then endofpath = pos(":",filename)
  84.         filename = substr(filename, endofpath+1)
  85.         if boxname = "" then boxname = filename
  86.         end
  87.     when upper(boxtype) = "CLIP" then do
  88.         objects = "Clip, "||word(info,2)||" objects"
  89.         if word(info,2)=1 then objects = "Clip, 1 object"
  90.         if boxname = "" then boxname = objects
  91.         end
  92.     when upper(boxtype) = "STRUCTURED" then do
  93.         objects = "Struct., "||word(info,2)||" objects"
  94.         if word(info,2)=1 then objects = "Struct., 1 object"
  95.         if boxname = "" then boxname = objects
  96.         end
  97.     when upper(boxtype) = "EMPTY" then do
  98.         if boxname = "" then boxname = "Empty"
  99.         end
  100.     otherwise boxname = "Unknown type of box"
  101. end
  102.  
  103. if numbered = 0 then boxname = boxname||" ("number")"
  104.  
  105. return boxname
  106.